fix bug where GC didn't always get updated properly
authorHavoc Pennington <hp@redhat.com>
Tue, 14 Nov 2000 01:08:28 +0000 (01:08 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Tue, 14 Nov 2000 01:08:28 +0000 (01:08 +0000)
2000-11-13  Havoc Pennington  <hp@redhat.com>

* gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug
where GC didn't always get updated properly

* demos/gtk-demo/textview.c (create_tags): Use subattributes
of fonts instead of setting the entire font

* gtk/testtext.c (fill_example_buffer): Use "size" instead of
setting entire font

* gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings

* gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into
a bunch of individually-settable font attributes. You can still
use the "font" and "font_desc" args, they just set all the font
attributes at once.

18 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
demos/gtk-demo/textview.c
gdk-pixbuf/ChangeLog
gdk-pixbuf/io-png.c
gtk/gtkdialog.c
gtk/gtktextdisplay.c
gtk/gtktextlayout.c
gtk/gtktexttag.c
gtk/gtktexttag.h
gtk/gtktextview.c
gtk/testtext.c
tests/testtext.c

index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index 21d9fea76ab26338180d64483ee79fadfd7059ee..ddae9ecd180a7ce2b7ad68b18edc05f1603d97a5 100644 (file)
@@ -1,3 +1,21 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextdisplay.c (gtk_text_render_state_update): fix bug 
+       where GC didn't always get updated properly
+
+       * demos/gtk-demo/textview.c (create_tags): Use subattributes
+       of fonts instead of setting the entire font
+
+       * gtk/testtext.c (fill_example_buffer): Use "size" instead of
+       setting entire font
+
+       * gtk/gtkdialog.c (gtk_dialog_add_button): Fix some warnings
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: Explode font_desc into 
+       a bunch of individually-settable font attributes. You can still 
+       use the "font" and "font_desc" args, they just set all the font
+       attributes at once.
+
 2000-11-13 Elliot Lee <sopwith@redhat.com>
        * gdk/gdk.h: Add a couple of missing G_GNUC_CONST's.
 
index d6ee7b42547d76cc92e44cc6313d5380f98fbb80..72c9b7e048e6d023554e298f8f6efde8d656de40 100644 (file)
@@ -71,13 +71,14 @@ create_tags (GtkTextBuffer *buffer)
    */
 
   tag = gtk_text_buffer_create_tag (buffer, "italic");
-  g_object_set (G_OBJECT (tag), "font", "sans italic", NULL);
+  g_object_set (G_OBJECT (tag), "style", PANGO_STYLE_ITALIC, NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "bold");
-  g_object_set (G_OBJECT (tag), "font", "sans bold", NULL);  
+  g_object_set (G_OBJECT (tag), "weight", PANGO_WEIGHT_BOLD, NULL);  
 
   tag = gtk_text_buffer_create_tag (buffer, "big");
-  g_object_set (G_OBJECT (tag), "font", "sans 120", NULL);
+  /* 70 points times the PANGO_SCALE factor */
+  g_object_set (G_OBJECT (tag), "size", 70 * PANGO_SCALE, NULL);
   
   tag = gtk_text_buffer_create_tag (buffer, "blue_foreground");
   g_object_set (G_OBJECT (tag), "foreground", "blue", NULL);  
@@ -141,13 +142,13 @@ create_tags (GtkTextBuffer *buffer)
   tag = gtk_text_buffer_create_tag (buffer, "superscript");
   g_object_set (G_OBJECT (tag),
                 "offset", 10,
-                "font", "Sans 8",
+                "size", 8 * PANGO_SCALE,
                 NULL);
   
   tag = gtk_text_buffer_create_tag (buffer, "subscript");
   g_object_set (G_OBJECT (tag),
                 "offset", -10,
-                "font", "Sans 8",
+                "size", 8 * PANGO_SCALE,
                 NULL); 
 }
 
index 1355b8cf1e13ad7e8b10207d0561352a294520a1..ee6e3550ba049a3a1659190c3cec3b9f82246242 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-13  Havoc Pennington  <hp@redhat.com>
+
+       * io-png.c (png_simple_error_callback): fix error message to not
+       say "save" since it's used for loading
+
 2000-11-11  Hans Breuer <Hans@Breuer.Org>
 
        * gdk-pixbuf-io.c : Fix all function prototype macros for self 
index bd945f7943ca44c06dcc865d508000127f5039ef..321956ebad590f3e0143eeaac78d4b08251e64ef 100644 (file)
@@ -155,7 +155,7 @@ png_simple_error_callback(png_structp png_save_ptr,
                 g_set_error (error,
                              GDK_PIXBUF_ERROR,
                              GDK_PIXBUF_ERROR_FAILED,
-                             _("Fatal error saving PNG image file: %s"),
+                             _("Fatal error in PNG image file: %s"),
                              error_msg);
         }
 }
index 2b7ef7307859c206756b79e308e10597414d2c1d..2c54881116cc6a931da40f508eaaea7d5e241b80 100644 (file)
@@ -387,8 +387,8 @@ gtk_dialog_add_button (GtkDialog   *dialog,
 {
   GtkWidget *button;
   
-  g_return_if_fail (GTK_IS_DIALOG (dialog));
-  g_return_if_fail (button_text != NULL);
+  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
+  g_return_val_if_fail (button_text != NULL, NULL);
 
   button = gtk_button_new_stock (button_text,
                                  gtk_window_get_default_accel_group (GTK_WINDOW (dialog)));
index 5e42b6439f74d63e5526293c1352b09a5b24b264..bc9ba182356bafb2a21b7c848ee788e1c2e3661c 100644 (file)
@@ -86,6 +86,7 @@ struct _GtkTextRenderState
   GtkWidget *widget;
 
   GtkTextAppearance *last_appearance;
+  GtkTextAppearance *last_bg_appearance;
   GdkGC *fg_gc;
   GdkGC *bg_gc;
   GdkRectangle clip_rect;
@@ -159,12 +160,12 @@ gtk_text_render_state_update (GtkTextRenderState *state,
 
   if (new_appearance->draw_bg)
     {
-      if (!state->last_appearance ||
-          !gdk_color_equal (&new_appearance->bg_color, &state->last_appearance->bg_color))
+      if (!state->last_bg_appearance ||
+          !gdk_color_equal (&new_appearance->bg_color, &state->last_bg_appearance->bg_color))
         gtk_text_render_state_set_color (state, state->bg_gc, &new_appearance->bg_color);
 
-      if (!state->last_appearance ||
-          new_appearance->bg_stipple != state->last_appearance->bg_stipple)
+      if (!state->last_bg_appearance ||
+          new_appearance->bg_stipple != state->last_bg_appearance->bg_stipple)
         {
           if (new_appearance->bg_stipple)
             {
@@ -176,6 +177,8 @@ gtk_text_render_state_update (GtkTextRenderState *state,
               gdk_gc_set_fill (state->bg_gc, GDK_SOLID);
             }
         }
+
+      state->last_bg_appearance = new_appearance;
     }
 
   state->last_appearance = new_appearance;
@@ -665,7 +668,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
       GtkTextLine *line = tmp_list->data;
 
       line_display = gtk_text_layout_get_line_display (layout, line, FALSE);
-
+      
       if (have_selection)
         {
           GtkTextIter line_start, line_end;
index e7cc89c2fd3c423bc4f88d0138c807374838d09e..be77b17a4535d690edbdc11d08e777f2adf913da 100644 (file)
@@ -775,7 +775,7 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
     y0 = 0;
   if (y1 < 0)
     y1 = 0;
-
+  
   /* Validate backwards from the anchor line to y0
    */
   line = gtk_text_iter_get_text_line (anchor);
@@ -792,7 +792,7 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
           line_data = gtk_text_line_get_data (line, layout);
 
           delta_height += line_data->height - old_height;
-
+          
           first_line = line;
           first_line_y = -seen;
           if (!last_line)
@@ -821,7 +821,7 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
           line_data = gtk_text_line_get_data (line, layout);
 
           delta_height += line_data->height - old_height;
-
+          
           if (!first_line)
             {
               first_line = line;
@@ -1229,7 +1229,7 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
 
 static void
 add_text_attrs (GtkTextLayout      *layout,
-                GtkTextAttributes *style,
+                GtkTextAttributes  *style,
                 gint                byte_count,
                 PangoAttrList      *attrs,
                 gint                start,
@@ -1237,7 +1237,7 @@ add_text_attrs (GtkTextLayout      *layout,
 {
   PangoAttribute *attr;
 
-  attr = pango_attr_font_desc_new (style->font_desc);
+  attr = pango_attr_font_desc_new (&style->font);
   attr->start_index = start;
   attr->end_index = start + byte_count;
 
@@ -1452,7 +1452,7 @@ add_preedit_attrs (GtkTextLayout     *layout,
       if (end == G_MAXINT)
        end = layout->preedit_len;
       
-      pango_attr_iterator_get_font (iter, style->font_desc,
+      pango_attr_iterator_get_font (iter, &style->font,
                                    &font_desc, size_only ? NULL : &extra_attrs);
       
       tmp_list = extra_attrs;
index 4f35a80b956f4d0a7d9d2dae23514fe190094cf5..98d77481c4ab866bf34e260fb4fd7b8c3de0aad7 100644 (file)
@@ -76,6 +76,13 @@ enum {
   ARG_FOREGROUND_STIPPLE,
   ARG_FONT,
   ARG_FONT_DESC,
+  ARG_FAMILY,
+  ARG_STYLE,
+  ARG_VARIANT,
+  ARG_WEIGHT,
+  ARG_STRETCH,
+  ARG_SIZE,
+  ARG_SIZE_POINTS,
   ARG_PIXELS_ABOVE_LINES,
   ARG_PIXELS_BELOW_LINES,
   ARG_PIXELS_INSIDE_WRAP,
@@ -101,7 +108,12 @@ enum {
   ARG_FOREGROUND_GDK_SET,
   ARG_BACKGROUND_STIPPLE_SET,
   ARG_FOREGROUND_STIPPLE_SET,
-  ARG_FONT_SET,
+  ARG_FAMILY_SET,
+  ARG_STYLE_SET,
+  ARG_VARIANT_SET,
+  ARG_WEIGHT_SET,
+  ARG_STRETCH_SET,
+  ARG_SIZE_SET,
   ARG_PIXELS_ABOVE_LINES_SET,
   ARG_PIXELS_BELOW_LINES_SET,
   ARG_PIXELS_INSIDE_WRAP_SET,
@@ -191,7 +203,21 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
   gtk_object_add_arg_type ("GtkTextTag::font", GTK_TYPE_STRING,
                            GTK_ARG_READWRITE, ARG_FONT);
   gtk_object_add_arg_type ("GtkTextTag::font_desc", GTK_TYPE_BOXED,
-                           GTK_ARG_READWRITE, ARG_FONT_DESC);
+                           GTK_ARG_READWRITE, ARG_FONT_DESC);      
+  gtk_object_add_arg_type ("GtkTextTag::family", GTK_TYPE_STRING,
+                           GTK_ARG_READWRITE, ARG_FAMILY);
+  gtk_object_add_arg_type ("GtkTextTag::style", GTK_TYPE_ENUM,
+                           GTK_ARG_READWRITE, ARG_STYLE);
+  gtk_object_add_arg_type ("GtkTextTag::variant", GTK_TYPE_ENUM,
+                           GTK_ARG_READWRITE, ARG_VARIANT);
+  gtk_object_add_arg_type ("GtkTextTag::weight", GTK_TYPE_ENUM,
+                           GTK_ARG_READWRITE, ARG_WEIGHT);
+  gtk_object_add_arg_type ("GtkTextTag::stretch", GTK_TYPE_ENUM,
+                           GTK_ARG_READWRITE, ARG_STRETCH);
+  gtk_object_add_arg_type ("GtkTextTag::size", GTK_TYPE_INT,
+                           GTK_ARG_READWRITE, ARG_SIZE);
+  gtk_object_add_arg_type ("GtkTextTag::size_points", GTK_TYPE_DOUBLE,
+                           GTK_ARG_READWRITE, ARG_SIZE_POINTS);
   gtk_object_add_arg_type ("GtkTextTag::foreground", GTK_TYPE_STRING,
                            GTK_ARG_WRITABLE, ARG_FOREGROUND);
   gtk_object_add_arg_type ("GtkTextTag::foreground_gdk", GTK_TYPE_GDK_COLOR,
@@ -238,9 +264,19 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
   gtk_object_add_arg_type ("GtkTextTag::background_stipple_set", GTK_TYPE_BOOL,
                            GTK_ARG_READWRITE, ARG_BACKGROUND_STIPPLE_SET);
   gtk_object_add_arg_type ("GtkTextTag::editable_set", GTK_TYPE_BOOL,
-                           GTK_ARG_READWRITE, ARG_EDITABLE_SET);
-  gtk_object_add_arg_type ("GtkTextTag::font_set", GTK_TYPE_BOOL,
-                           GTK_ARG_READWRITE, ARG_FONT_SET);
+                           GTK_ARG_READWRITE, ARG_EDITABLE_SET);  
+  gtk_object_add_arg_type ("GtkTextTag::family_set", GTK_TYPE_BOOL,
+                           GTK_ARG_READWRITE, ARG_FAMILY_SET);
+  gtk_object_add_arg_type ("GtkTextTag::style_set", GTK_TYPE_BOOL,
+                           GTK_ARG_READWRITE, ARG_STYLE_SET);
+  gtk_object_add_arg_type ("GtkTextTag::variant_set", GTK_TYPE_BOOL,
+                           GTK_ARG_READWRITE, ARG_VARIANT_SET);
+  gtk_object_add_arg_type ("GtkTextTag::weight_set", GTK_TYPE_BOOL,
+                           GTK_ARG_READWRITE, ARG_WEIGHT_SET);
+  gtk_object_add_arg_type ("GtkTextTag::stretch_set", GTK_TYPE_BOOL,
+                           GTK_ARG_READWRITE, ARG_STRETCH_SET);
+  gtk_object_add_arg_type ("GtkTextTag::size_set", GTK_TYPE_BOOL,
+                           GTK_ARG_READWRITE, ARG_SIZE_SET);
   gtk_object_add_arg_type ("GtkTextTag::foreground_set", GTK_TYPE_BOOL,
                            GTK_ARG_READWRITE, ARG_FOREGROUND_SET);
   gtk_object_add_arg_type ("GtkTextTag::foreground_gdk_set", GTK_TYPE_BOOL,
@@ -390,6 +426,44 @@ set_fg_color (GtkTextTag *tag, GdkColor *color)
     }
 }
 
+static void
+set_font_description (GtkTextTag           *text_tag,
+                      PangoFontDescription *font_desc)
+{
+  if (font_desc != NULL)
+    {
+      /* pango_font_description_from_string() will sometimes return
+       * a NULL family or -1 size, so handle those cases.
+       */
+      
+      if (font_desc->family_name)
+        gtk_object_set (GTK_OBJECT (text_tag),
+                        "family", font_desc->family_name,
+                        NULL);
+      
+      if (font_desc->size >= 0)
+        gtk_object_set (GTK_OBJECT (text_tag),
+                        "size", font_desc->size,
+                        NULL);
+        
+      gtk_object_set (GTK_OBJECT (text_tag),
+                      "style", font_desc->style,
+                      "variant", font_desc->variant,
+                      "weight", font_desc->weight,
+                      "stretch", font_desc->stretch,
+                      NULL);
+    }
+  else
+    {      
+      text_tag->family_set = FALSE;
+      text_tag->style_set = FALSE;
+      text_tag->variant_set = FALSE;
+      text_tag->weight_set = FALSE;
+      text_tag->stretch_set = FALSE;
+      text_tag->size_set = FALSE;
+    }
+}
+
 static void
 gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
 {
@@ -491,11 +565,10 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
         if (name)
           font_desc = pango_font_description_from_string (name);
 
-        if (text_tag->values->font_desc)
-          pango_font_description_free (text_tag->values->font_desc);
-
-        text_tag->font_set = (font_desc != NULL);
-        text_tag->values->font_desc = font_desc;
+        set_font_description (text_tag, font_desc);
+        
+        if (font_desc)
+          pango_font_description_free (font_desc); 
 
         size_changed = TRUE;
       }
@@ -507,20 +580,56 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
 
         font_desc = GTK_VALUE_BOXED (*arg);
 
-        if (text_tag->values->font_desc)
-          pango_font_description_free (text_tag->values->font_desc);
-
-        if (font_desc)
-          text_tag->values->font_desc = pango_font_description_copy (font_desc);
-        else
-          text_tag->values->font_desc = NULL;
-
-        text_tag->font_set = (font_desc != NULL);
+        set_font_description (text_tag, font_desc);
 
         size_changed = TRUE;
       }
       break;
 
+    case ARG_FAMILY:
+      if (text_tag->values->font.family_name)
+        g_free (text_tag->values->font.family_name);
+      text_tag->values->font.family_name = g_strdup (GTK_VALUE_STRING (*arg));
+      text_tag->family_set = TRUE;
+      size_changed = TRUE;
+      break;
+
+    case ARG_STYLE:
+      text_tag->values->font.style = GTK_VALUE_ENUM (*arg);
+      text_tag->style_set = TRUE;
+      size_changed = TRUE;
+      break;
+
+    case ARG_VARIANT:
+      text_tag->values->font.variant = GTK_VALUE_ENUM (*arg);
+      text_tag->variant_set = TRUE;
+      size_changed = TRUE;
+      break;
+
+    case ARG_WEIGHT:
+      text_tag->values->font.weight = GTK_VALUE_ENUM (*arg);
+      text_tag->weight_set = TRUE;
+      size_changed = TRUE;
+      break;
+
+    case ARG_STRETCH:
+      text_tag->values->font.stretch = GTK_VALUE_ENUM (*arg);
+      text_tag->stretch_set = TRUE;
+      size_changed = TRUE;
+      break;
+
+    case ARG_SIZE:
+      text_tag->values->font.size = GTK_VALUE_INT (*arg);
+      text_tag->size_set = TRUE;
+      size_changed = TRUE;
+      break;
+
+    case ARG_SIZE_POINTS:
+      text_tag->values->font.size = GTK_VALUE_DOUBLE (*arg) * PANGO_SCALE;
+      text_tag->size_set = TRUE;
+      size_changed = TRUE;
+      break;
+      
     case ARG_PIXELS_ABOVE_LINES:
       text_tag->pixels_above_lines_set = TRUE;
       text_tag->values->pixels_above_lines = GTK_VALUE_INT (*arg);
@@ -636,17 +745,54 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
 
     case ARG_BACKGROUND_STIPPLE_SET:
       text_tag->bg_stipple_set = GTK_VALUE_BOOL (*arg);
+      if (!text_tag->bg_stipple_set &&
+          text_tag->values->appearance.bg_stipple)
+        {
+          g_object_unref (G_OBJECT (text_tag->values->appearance.bg_stipple));
+          text_tag->values->appearance.bg_stipple = NULL;
+        }
       break;
 
     case ARG_FOREGROUND_STIPPLE_SET:
       text_tag->fg_stipple_set = GTK_VALUE_BOOL (*arg);
+      if (!text_tag->fg_stipple_set &&
+          text_tag->values->appearance.fg_stipple)
+        {
+          g_object_unref (G_OBJECT (text_tag->values->appearance.fg_stipple));
+          text_tag->values->appearance.fg_stipple = NULL;
+        }
       break;
 
-    case ARG_FONT_SET:
-      text_tag->font_set = GTK_VALUE_BOOL (*arg);
+    case ARG_FAMILY_SET:
+      text_tag->family_set = GTK_VALUE_BOOL (*arg);
       size_changed = TRUE;
       break;
 
+    case ARG_STYLE_SET:
+      text_tag->style_set = GTK_VALUE_BOOL (*arg);
+      size_changed = TRUE;
+      break;
+
+    case ARG_VARIANT_SET:
+      text_tag->variant_set = GTK_VALUE_BOOL (*arg);
+      size_changed = TRUE;
+      break;
+
+    case ARG_WEIGHT_SET:
+      text_tag->weight_set = GTK_VALUE_BOOL (*arg);
+      size_changed = TRUE;
+      break;
+
+    case ARG_STRETCH_SET:
+      text_tag->stretch_set = GTK_VALUE_BOOL (*arg);
+      size_changed = TRUE;
+      break;
+
+    case ARG_SIZE_SET:
+      text_tag->size_set = GTK_VALUE_BOOL (*arg);
+      size_changed = TRUE;
+      break;
+      
     case ARG_PIXELS_ABOVE_LINES_SET:
       text_tag->pixels_above_lines_set = GTK_VALUE_BOOL (*arg);
       size_changed = TRUE;
@@ -775,27 +921,72 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
       break;
 
     case ARG_BACKGROUND_STIPPLE:
-      GTK_VALUE_BOXED (*arg) = tag->values->appearance.bg_stipple;
+      if (tag->bg_stipple_set)
+        GTK_VALUE_BOXED (*arg) = tag->values->appearance.bg_stipple;
+      else
+        GTK_VALUE_BOXED (*arg) = NULL;
       break;
 
     case ARG_FOREGROUND_STIPPLE:
-      GTK_VALUE_BOXED (*arg) = tag->values->appearance.fg_stipple;
+      if (tag->fg_stipple_set)
+        GTK_VALUE_BOXED (*arg) = tag->values->appearance.fg_stipple;
+      else
+        GTK_VALUE_BOXED (*arg) = NULL;
       break;
 
     case ARG_FONT:
-      if (tag->values->font_desc)
-        GTK_VALUE_STRING (*arg) = pango_font_description_to_string (tag->values->font_desc);
+      if (tag->family_set &&
+          tag->style_set &&
+          tag->variant_set &&
+          tag->size_set &&
+          tag->stretch_set &&
+          tag->weight_set)
+        GTK_VALUE_STRING (*arg) =
+          pango_font_description_to_string (&tag->values->font);
       else
         GTK_VALUE_STRING (*arg) = NULL;
       break;
 
     case ARG_FONT_DESC:
-      if (tag->values->font_desc)
-        GTK_VALUE_BOXED (*arg) = pango_font_description_copy (tag->values->font_desc);
+      if (tag->family_set &&
+          tag->style_set &&
+          tag->variant_set &&
+          tag->size_set &&
+          tag->stretch_set &&
+          tag->weight_set)
+        GTK_VALUE_BOXED (*arg) = pango_font_description_copy (&tag->values->font);
       else
         GTK_VALUE_BOXED (*arg) = NULL;
       break;
 
+    case ARG_FAMILY:
+      GTK_VALUE_STRING (*arg) = g_strdup (tag->values->font.family_name);
+      break;
+
+    case ARG_STYLE:
+      GTK_VALUE_ENUM (*arg) = tag->values->font.style;
+      break;
+
+    case ARG_VARIANT:
+      GTK_VALUE_ENUM (*arg) = tag->values->font.variant;
+      break;
+
+    case ARG_WEIGHT:
+      GTK_VALUE_ENUM (*arg) = tag->values->font.weight;
+      break;
+
+    case ARG_STRETCH:
+      GTK_VALUE_ENUM (*arg) = tag->values->font.stretch;
+      break;
+
+    case ARG_SIZE:
+      GTK_VALUE_INT (*arg) = tag->values->font.size;
+      break;
+
+    case ARG_SIZE_POINTS:
+      GTK_VALUE_DOUBLE (*arg) = ((double)tag->values->font.size) / (double)PANGO_SCALE;
+      break;
+      
     case ARG_PIXELS_ABOVE_LINES:
       GTK_VALUE_INT (*arg) = tag->values->pixels_above_lines;
       break;
@@ -875,10 +1066,30 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
       GTK_VALUE_BOOL (*arg) = tag->fg_stipple_set;
       break;
 
-    case ARG_FONT_SET:
-      GTK_VALUE_BOOL (*arg) = tag->font_set;
+    case ARG_FAMILY_SET:
+      GTK_VALUE_BOOL (*arg) = tag->family_set;
       break;
 
+    case ARG_STYLE_SET:
+      GTK_VALUE_BOOL (*arg) = tag->style_set;
+      break;
+
+    case ARG_VARIANT_SET:
+      GTK_VALUE_BOOL (*arg) = tag->variant_set;
+      break;
+
+    case ARG_WEIGHT_SET:
+      GTK_VALUE_BOOL (*arg) = tag->weight_set;
+      break;
+
+    case ARG_STRETCH_SET:
+      GTK_VALUE_BOOL (*arg) = tag->stretch_set;
+      break;
+
+    case ARG_SIZE_SET:
+      GTK_VALUE_BOOL (*arg) = tag->size_set;
+      break;
+      
     case ARG_PIXELS_ABOVE_LINES_SET:
       GTK_VALUE_BOOL (*arg) = tag->pixels_above_lines_set;
       break;
@@ -1145,7 +1356,7 @@ gtk_text_attributes_new (void)
 {
   GtkTextAttributes *values;
 
-  values = g_new0(GtkTextAttributes, 1);
+  values = g_new0 (GtkTextAttributes, 1);
 
   /* 0 is a valid value for most of the struct */
 
@@ -1186,19 +1397,22 @@ gtk_text_attributes_copy (GtkTextAttributes *src,
 
   if (dest->language)
     g_free (dest->language);
+
+  if (dest->font.family_name)
+    g_free (dest->font.family_name);
   
   /* Copy */
   orig_refcount = dest->refcount;
 
   *dest = *src;
 
-  dest->font_desc = pango_font_description_copy (src->font_desc);
-
   if (src->tabs)
     dest->tabs = pango_tab_array_copy (src->tabs);
 
   dest->language = g_strdup (src->language);
 
+  dest->font.family_name = g_strdup (src->font.family_name);
+  
   dest->refcount = orig_refcount;
   dest->realized = FALSE;
 }
@@ -1226,9 +1440,6 @@ gtk_text_attributes_unref (GtkTextAttributes *values)
       if (values->appearance.bg_stipple)
         gdk_bitmap_unref (values->appearance.bg_stipple);
 
-      if (values->font_desc)
-        pango_font_description_free (values->font_desc);
-
       if (values->appearance.fg_stipple)
         gdk_bitmap_unref (values->appearance.fg_stipple);
 
@@ -1238,6 +1449,9 @@ gtk_text_attributes_unref (GtkTextAttributes *values)
       if (values->language)
         g_free (values->language);
 
+      if (values->font.family_name)
+        g_free (values->font.family_name);
+      
       g_free (values);
     }
 }
@@ -1287,8 +1501,8 @@ gtk_text_attributes_unrealize (GtkTextAttributes *values,
 
 void
 gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
-                                    GtkTextTag**        tags,
-                                    guint               n_tags)
+                                    GtkTextTag**       tags,
+                                    guint              n_tags)
 {
   guint n = 0;
 
@@ -1308,7 +1522,9 @@ gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
 
           dest->appearance.draw_bg = TRUE;
         }
-
+      if (tag->fg_color_set)
+        dest->appearance.fg_color = vals->appearance.fg_color;
+      
       if (tag->bg_stipple_set)
         {
           gdk_bitmap_ref (vals->appearance.bg_stipple);
@@ -1319,16 +1535,6 @@ gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
           dest->appearance.draw_bg = TRUE;
         }
 
-      if (tag->fg_color_set)
-        dest->appearance.fg_color = vals->appearance.fg_color;
-
-      if (tag->font_set)
-        {
-          if (dest->font_desc)
-            pango_font_description_free (dest->font_desc);
-          dest->font_desc = pango_font_description_copy (vals->font_desc);
-        }
-
       if (tag->fg_stipple_set)
         {
           gdk_bitmap_ref (vals->appearance.fg_stipple);
@@ -1337,6 +1543,29 @@ gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
           dest->appearance.fg_stipple = vals->appearance.fg_stipple;
         }
 
+      if (tag->family_set)
+        {
+          if (dest->font.family_name)
+            g_free (dest->font.family_name);
+
+          dest->font.family_name = g_strdup (vals->font.family_name);
+        }
+
+      if (tag->style_set)
+        dest->font.style = vals->font.style;
+
+      if (tag->variant_set)
+        dest->font.variant = vals->font.variant;
+
+      if (tag->weight_set)
+        dest->font.weight = vals->font.weight;
+
+      if (tag->stretch_set)
+        dest->font.stretch = vals->font.stretch;
+
+      if (tag->size_set)
+        dest->font.size = vals->font.size;
+
       if (tag->justify_set)
         dest->justify = vals->justify;
 
@@ -1405,7 +1634,12 @@ gtk_text_tag_affects_size (GtkTextTag *tag)
   g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
 
   return
-    tag->font_set ||
+    tag->family_set ||
+    tag->style_set ||
+    tag->variant_set ||
+    tag->weight_set ||
+    tag->size_set ||
+    tag->stretch_set ||
     tag->justify_set ||
     tag->left_margin_set ||
     tag->indent_set ||
index 992f31556c0c164581b156c60af59b183ddee050..4924b1c102c2c038a459fe313b9f620dc5dec905 100644 (file)
@@ -61,7 +61,12 @@ struct _GtkTextTag
   guint bg_color_set : 1;
   guint bg_stipple_set : 1;
   guint fg_color_set : 1;
-  guint font_set : 1;
+  guint family_set : 1;
+  guint style_set : 1;
+  guint variant_set : 1;
+  guint weight_set : 1;
+  guint stretch_set : 1;
+  guint size_set : 1;
   guint fg_stipple_set : 1;
   guint justify_set : 1;
   guint left_margin_set : 1;
@@ -142,7 +147,8 @@ struct _GtkTextAttributes
   GtkJustification justify;
   GtkTextDirection direction;
 
-  PangoFontDescription *font_desc;
+  /* Individual chunks of this can be set/unset as a group */
+  PangoFontDescription font;
 
   gint left_margin;
 
index 2bfb1eaa284bc73be32de2c25d8b95c52bf74245..437b9bf5cf574ee1d339808a1722e65710775553 100644 (file)
@@ -21,7 +21,7 @@
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 #include <string.h>
@@ -222,7 +222,7 @@ static GtkAdjustment* get_vadjustment            (GtkTextView       *text_view);
 
 static void gtk_text_view_popup_menu             (GtkTextView       *text_view,
                                                  GdkEventButton    *event);
+
 /* Container methods */
 static void gtk_text_view_add    (GtkContainer *container,
                                   GtkWidget    *child);
@@ -394,14 +394,14 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
   gtk_object_add_arg_type ("GtkTextView::justify", GTK_TYPE_ENUM,
                            GTK_ARG_READWRITE, ARG_JUSTIFY);
   gtk_object_add_arg_type ("GtkTextView::left_margin", GTK_TYPE_INT,
-                           GTK_ARG_READWRITE, ARG_LEFT_MARGIN);  
+                           GTK_ARG_READWRITE, ARG_LEFT_MARGIN);
   gtk_object_add_arg_type ("GtkTextView::right_margin", GTK_TYPE_INT,
                            GTK_ARG_READWRITE, ARG_RIGHT_MARGIN);
   gtk_object_add_arg_type ("GtkTextView::indent", GTK_TYPE_INT,
                            GTK_ARG_READWRITE, ARG_INDENT);
   gtk_object_add_arg_type ("GtkTextView::tabs", GTK_TYPE_POINTER, /* FIXME */
                            GTK_ARG_READWRITE, ARG_TABS);
-    
+
   /*
    * Signals
    */
@@ -700,7 +700,7 @@ gtk_text_view_init (GtkTextView *text_view)
   text_view->indent = 0;
   text_view->tabs = NULL;
   text_view->editable = TRUE;
-  
+
   gtk_drag_dest_set (widget,
                      GTK_DEST_DEFAULT_DROP,
                      target_table, G_N_ELEMENTS (target_table),
@@ -719,7 +719,7 @@ gtk_text_view_init (GtkTextView *text_view)
 
   gtk_signal_connect (GTK_OBJECT (text_view->im_context), "preedit_changed",
                      GTK_SIGNAL_FUNC (gtk_text_view_preedit_changed_handler), text_view);
-  
+
   text_view->cursor_visible = TRUE;
 
   text_view->text_window = text_window_new (GTK_TEXT_WINDOW_TEXT,
@@ -731,7 +731,7 @@ gtk_text_view_init (GtkTextView *text_view)
 
 /**
  * gtk_text_view_new:
- * 
+ *
  * Creates a new #GtkTextView. If you don't call gtk_text_view_set_buffer()
  * before using the text view, an empty default buffer will be created
  * for you. Get the buffer with gtk_text_view_get_buffer(). If you want
@@ -748,14 +748,14 @@ gtk_text_view_new (void)
 /**
  * gtk_text_view_new_with_buffer:
  * @buffer: a #GtkTextBuffer
- * 
+ *
  * Creates a new #GtkTextView widget displaying the buffer
  * @buffer. One buffer can be shared among many widgets.
  * @buffer may be NULL to create a default buffer, in which case
  * this function is equivalent to gtk_text_view_new(). The
  * text view adds its own reference count to the buffer; it does not
  * take over an existing reference.
- * 
+ *
  * Return value: a new #GtkTextView.
  **/
 GtkWidget*
@@ -780,7 +780,7 @@ gtk_text_view_new_with_buffer (GtkTextBuffer *buffer)
  * added to @buffer. If you owned a reference to @buffer before passing it
  * to this function, you must remove that reference yourself; #GtkTextView
  * will not "adopt" it.
- * 
+ *
  **/
 void
 gtk_text_view_set_buffer (GtkTextView   *text_view,
@@ -797,7 +797,7 @@ gtk_text_view_set_buffer (GtkTextView   *text_view,
       /* Destroy all anchored children */
       GSList *tmp_list;
       GSList *copy;
-      
+
       copy = g_slist_copy (text_view->children);
       tmp_list = copy;
       while (tmp_list != NULL)
@@ -809,12 +809,12 @@ gtk_text_view_set_buffer (GtkTextView   *text_view,
               gtk_widget_destroy (vc->widget);
               /* vc may now be invalid! */
             }
-            
+
           tmp_list = g_slist_next (tmp_list);
         }
 
       g_slist_free (copy);
-      
+
       gtk_signal_disconnect_by_func (GTK_OBJECT (text_view->buffer),
                                      gtk_text_view_mark_set_handler, text_view);
       gtk_object_unref (GTK_OBJECT (text_view->buffer));
@@ -870,11 +870,11 @@ get_buffer (GtkTextView *text_view)
 /**
  * gtk_text_view_get_buffer:
  * @text_view: a #GtkTextView
- * 
+ *
  * Returns the #GtkTextBuffer being displayed by this text view.
  * The reference count on the buffer is not incremented; the caller
  * of this function won't own a new reference.
- * 
+ *
  * Return value: a #GtkTextBuffer
  **/
 GtkTextBuffer*
@@ -897,7 +897,7 @@ gtk_text_view_get_buffer (GtkTextView *text_view)
  * currently-displayed portion.  If you have coordinates from an
  * event, you have to convert those to buffer coordinates with
  * gtk_text_view_window_to_buffer_coords().
- * 
+ *
  **/
 void
 gtk_text_view_get_iter_at_location (GtkTextView *text_view,
@@ -925,7 +925,7 @@ gtk_text_view_get_iter_at_location (GtkTextView *text_view,
  * The rectangle position is in buffer coordinates; use
  * gtk_text_view_buffer_to_window_coords() to convert these
  * coordinates to coordinates for one of the windows in the text view.
- * 
+ *
  **/
 void
 gtk_text_view_get_iter_location (GtkTextView       *text_view,
@@ -948,7 +948,7 @@ gtk_text_view_get_iter_location (GtkTextView       *text_view,
  * Gets the y coordinate of the top of the line containing @iter,
  * and the height of the line. The coordinate is a buffer coordinate;
  * convert to window coordinates with gtk_text_view_buffer_to_window_coords().
- * 
+ *
  **/
 void
 gtk_text_view_get_line_yrange (GtkTextView       *text_view,
@@ -971,7 +971,7 @@ gtk_text_view_get_line_yrange (GtkTextView       *text_view,
  * @target_iter: a #GtkTextIter
  * @y: a y coordinate
  * @line_top: return location for top coordinate of the line
- * 
+ *
  * Gets the #GtkTextIter at the start of the line containing
  * the coordinate @y. @y is in buffer coordinates, convert from
  * window coordinates with gtk_text_view_window_to_buffer_coords().
@@ -1135,13 +1135,13 @@ gtk_text_view_scroll_to_mark_adjusted (GtkTextView *text_view,
  * @text_view: a #GtkTextView
  * @mark: a #GtkTextMark
  * @mark_within_margin: a margin
- * 
+ *
  * Scrolls @text_view so that @mark is on the screen. If
  * @mark_within_margin is nonzero, the mark will be moved onscreen by
  * that many pixels. For example, if @mark_within_margin is 5, the
  * mark will be at least 5 pixels away from the edge of the screen,
  * if possible.
- * 
+ *
  * Return value: TRUE if scrolling occurred
  **/
 gboolean
@@ -1170,10 +1170,10 @@ clamp_iter_onscreen (GtkTextView *text_view, GtkTextIter *iter)
  * gtk_text_view_move_mark_onscreen:
  * @text_view: a #GtkTextView
  * @mark: a #GtkTextMark
- * 
+ *
  * Moves a mark within the buffer so that it's
  * located within the currently-visible text area.
- * 
+ *
  * Return value: %TRUE if scrolling occurred
  **/
 gboolean
@@ -1200,7 +1200,7 @@ gtk_text_view_move_mark_onscreen (GtkTextView *text_view,
  * gtk_text_view_get_visible_rect:
  * @text_view: a #GtkTextView
  * @visible_rect: rectangle to fill
- * 
+ *
  * Fills @visible_rect with the currently-visible
  * region of the buffer, in buffer coordinates. Convert to window coordinates
  * with gtk_text_view_buffer_to_window_coords().
@@ -1229,7 +1229,7 @@ gtk_text_view_get_visible_rect (GtkTextView  *text_view,
  * gtk_text_view_set_wrap_mode:
  * @text_view: a #GtkTextView
  * @wrap_mode: a #GtkWrapMode
- * 
+ *
  * Sets the line wrapping for the view.
  **/
 void
@@ -1254,9 +1254,9 @@ gtk_text_view_set_wrap_mode (GtkTextView *text_view,
 /**
  * gtk_text_view_get_wrap_mode:
  * @text_view: a #GtkTextView
- * 
+ *
  * Gets the line wrapping for the view.
- * 
+ *
  * Return value: the line wrap setting
  **/
 GtkWrapMode
@@ -1272,7 +1272,7 @@ gtk_text_view_get_wrap_mode (GtkTextView *text_view)
  * gtk_text_view_set_editable:
  * @text_view: a #GtkTextView
  * @setting: whether it's editable
- * 
+ *
  * Sets the default editability of the #GtkTextView. You can override
  * this default setting with tags in the buffer, using the "editable"
  * attribute of tags.
@@ -1298,10 +1298,10 @@ gtk_text_view_set_editable (GtkTextView *text_view,
 /**
  * gtk_text_view_get_editable:
  * @text_view: a #GtkTextView
- * 
+ *
  * Returns the default editability of the #GtkTextView. Tags in the
  * buffer may override this setting for some ranges of text.
- * 
+ *
  * Return value: whether text is editable by default
  **/
 gboolean
@@ -1395,7 +1395,7 @@ gtk_text_view_set_justification (GtkTextView     *text_view,
                                  GtkJustification justify)
 {
   g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
-  
+
   if (text_view->justify != justify)
     {
       text_view->justify = justify;
@@ -1530,7 +1530,7 @@ gtk_text_view_get_tabs (GtkTextView *text_view)
  * gtk_text_view_set_cursor_visible:
  * @text_view: a #GtkTextView
  * @setting: whether to show the insertion cursor
- * 
+ *
  * Toggles whether the insertion point is displayed. A buffer with no editable
  * text probably shouldn't have a visible cursor, so you may want to turn
  * the cursor off.
@@ -1565,9 +1565,9 @@ gtk_text_view_set_cursor_visible    (GtkTextView   *text_view,
 /**
  * gtk_text_view_get_cursor_visible:
  * @text_view: a #GtkTextView
- * 
+ *
  * Find out whether the cursor is being displayed.
- * 
+ *
  * Return value: whether the insertion mark is visible
  **/
 gboolean
@@ -1582,10 +1582,10 @@ gtk_text_view_get_cursor_visible    (GtkTextView   *text_view)
 /**
  * gtk_text_view_place_cursor_onscreen:
  * @text_view: a #GtkTextView
- * 
+ *
  * Moves the cursor to the currently visible region of the
  * buffer, it it isn't there already.
- * 
+ *
  * Return value: TRUE if the cursor had to be moved.
  **/
 gboolean
@@ -1629,7 +1629,7 @@ gtk_text_view_finalize (GObject *object)
   text_view = GTK_TEXT_VIEW (object);
 
   g_return_if_fail (text_view->buffer == NULL);
-  
+
   if (text_view->hadjustment)
     gtk_object_unref (GTK_OBJECT (text_view->hadjustment));
   if (text_view->vadjustment)
@@ -1710,7 +1710,7 @@ gtk_text_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
     case ARG_TABS:
       gtk_text_view_set_tabs (text_view, GTK_VALUE_POINTER (*arg));
       break;
-      
+
     default:
       g_assert_not_reached ();
       break;
@@ -1773,7 +1773,7 @@ gtk_text_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
     case ARG_TABS:
       GTK_VALUE_POINTER (*arg) = gtk_text_view_get_tabs (text_view);
       break;
-      
+
     default:
       arg->type = GTK_TYPE_INVALID;
       break;
@@ -1786,7 +1786,7 @@ gtk_text_view_size_request (GtkWidget      *widget,
 {
   GtkTextView *text_view;
   GSList *tmp_list;
-  
+
   text_view = GTK_TEXT_VIEW (widget);
 
   requisition->width = text_view->text_window->requisition.width + FOCUS_EDGE_WIDTH * 2;
@@ -1813,11 +1813,11 @@ gtk_text_view_size_request (GtkWidget      *widget,
         {
           GtkRequisition child_req;
           GtkRequisition old_req;
-          
+
           old_req = child->widget->requisition;
 
-          gtk_widget_size_request (child->widget, &child_req); 
-          
+          gtk_widget_size_request (child->widget, &child_req);
+
           if (text_view->layout &&
               (old_req.width != child_req.width ||
                old_req.height != child_req.height))
@@ -1828,7 +1828,7 @@ gtk_text_view_size_request (GtkWidget      *widget,
         {
 
         }
-          
+
       tmp_list = g_slist_next (tmp_list);
     }
 }
@@ -1839,7 +1839,7 @@ gtk_text_view_allocate_children (GtkTextView *text_view)
   GSList *tmp_list;
 
   return;
-  
+
   tmp_list = text_view->children;
   while (tmp_list != NULL)
     {
@@ -1861,9 +1861,9 @@ gtk_text_view_allocate_children (GtkTextView *text_view)
         }
       else
         {
-          
+
         }
-          
+
       tmp_list = g_slist_next (tmp_list);
     }
 }
@@ -1883,7 +1883,7 @@ gtk_text_view_size_allocate (GtkWidget *widget,
   GdkRectangle right_rect;
   GdkRectangle top_rect;
   GdkRectangle bottom_rect;
-  
+
   text_view = GTK_TEXT_VIEW (widget);
 
   widget->allocation = *allocation;
@@ -1982,7 +1982,7 @@ gtk_text_view_size_allocate (GtkWidget *widget,
                                     SCREEN_WIDTH (text_view));
 
   gtk_text_view_allocate_children (text_view);
-  
+
   gtk_text_view_validate_onscreen (text_view);
   gtk_text_view_scroll_calc_now (text_view);
 
@@ -2043,6 +2043,7 @@ gtk_text_view_validate_onscreen (GtkTextView *text_view)
     {
       GtkTextIter first_para;
       gtk_text_view_get_first_para_iter (text_view, &first_para);
+
       gtk_text_layout_validate_yrange (text_view->layout,
                                        &first_para,
                                        0,
@@ -2203,7 +2204,7 @@ static void
 gtk_text_view_unrealize (GtkWidget *widget)
 {
   GtkTextView *text_view;
-  
+
   text_view = GTK_TEXT_VIEW (widget);
 
   if (text_view->first_validate_idle)
@@ -2217,13 +2218,13 @@ gtk_text_view_unrealize (GtkWidget *widget)
       g_source_remove (text_view->incremental_validate_idle);
       text_view->incremental_validate_idle = 0;
     }
-  
+
   if (text_view->popup_menu)
     {
       gtk_widget_destroy (text_view->popup_menu);
       text_view->popup_menu = NULL;
     }
-   
+
   text_window_unrealize (text_view->text_window);
 
   if (text_view->left_window)
@@ -2499,7 +2500,7 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
   if (event->type == GDK_BUTTON_PRESS)
     {
       gtk_text_view_reset_im_context (text_view);
-   
+
       if (event->button == 1)
         {
           /* If we're in the selection, start a drag copy/move of the
@@ -2736,7 +2737,7 @@ gtk_text_view_draw (GtkWidget *widget, GdkRectangle *area)
   text_view = GTK_TEXT_VIEW (widget);
 
   gtk_text_view_paint (widget, area);
-  
+
   /* If the area overlaps the "edge" of the widget, draw the focus
    * rectangle
    */
@@ -2745,7 +2746,7 @@ gtk_text_view_draw (GtkWidget *widget, GdkRectangle *area)
       (area->x + area->width) > (widget->allocation.width - FOCUS_EDGE_WIDTH) ||
       (area->y + area->height) > (widget->allocation.height - FOCUS_EDGE_WIDTH))
     gtk_widget_draw_focus (widget);
-  
+
   /* Synthesize expose events for the user-drawn border windows,
    * just as we would for a drawing area.
    */
@@ -2773,14 +2774,14 @@ gtk_text_view_draw (GtkWidget *widget, GdkRectangle *area)
 
 static gint
 gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
-{  
+{
   if (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
                                                  GTK_TEXT_WINDOW_TEXT))
     gtk_text_view_paint (widget, &event->area);
 
   if (event->window == widget->window)
     gtk_widget_draw_focus (widget);
-  
+
   return TRUE;
 }
 
@@ -2850,7 +2851,7 @@ gtk_text_view_remove (GtkContainer *container,
     }
 
   g_assert (iter != NULL); /* be sure we had the child in the list */
-  
+
   text_view->children = g_slist_remove (text_view->children, vc);
 
   gtk_widget_unparent (vc->widget);
@@ -2955,7 +2956,7 @@ gtk_text_view_move_cursor (GtkTextView     *text_view,
   gint cursor_x_pos = 0;
 
   gtk_text_view_reset_im_context (text_view);
-   
+
   if (step == GTK_MOVEMENT_PAGES)
     {
       gtk_text_view_scroll_pages (text_view, count);
@@ -3162,7 +3163,7 @@ gtk_text_view_delete_from_cursor (GtkTextView   *text_view,
   gboolean leave_one = FALSE;
 
   gtk_text_view_reset_im_context (text_view);
-  
+
   if (type == GTK_DELETE_CHARS)
     {
       /* Char delete deletes the selection, if one exists */
@@ -3589,10 +3590,11 @@ gtk_text_view_set_attributes_from_style (GtkTextView        *text_view,
   values->appearance.bg_color = style->base[GTK_STATE_NORMAL];
   values->appearance.fg_color = style->fg[GTK_STATE_NORMAL];
 
-  if (values->font_desc)
-    pango_font_description_free (values->font_desc);
+  if (values->font.family_name)
+    g_free (values->font.family_name);
 
-  values->font_desc = pango_font_description_copy (style->font_desc);
+  values->font = *style->font_desc;
+  values->font.family_name = g_strdup (style->font_desc->family_name);
 }
 
 static void
@@ -3650,7 +3652,7 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
       style->right_margin = text_view->right_margin;
       style->indent = text_view->indent;
       style->tabs = text_view->tabs ? pango_tab_array_copy (text_view->tabs) : NULL;
-      
+
       style->wrap_mode = text_view->wrap_mode;
       style->justify = text_view->justify;
       style->direction = gtk_widget_get_direction (GTK_WIDGET (text_view));
@@ -3764,7 +3766,7 @@ gtk_text_view_drag_data_get (GtkWidget        *widget,
       gchar *str;
       GtkTextIter start;
       GtkTextIter end;
-      
+
       str = NULL;
 
       if (gtk_text_buffer_get_selection_bounds (get_buffer (text_view),
@@ -3912,9 +3914,9 @@ insert_text_data (GtkTextView      *text_view,
                   GtkSelectionData *selection_data)
 {
   gchar *str;
-  
+
   str = gtk_selection_data_get_text (selection_data);
-  
+
   if (str)
     {
       gtk_text_buffer_insert_interactive (get_buffer (text_view),
@@ -3954,15 +3956,15 @@ gtk_text_view_drag_data_received (GtkWidget        *widget,
       GtkTextBuffer *src_buffer = NULL;
       GtkTextIter start, end;
       gboolean copy_tags = TRUE;
-      
+
       if (selection_data->length != sizeof (src_buffer))
         return;
-          
+
       memcpy (&src_buffer, selection_data->data, sizeof (src_buffer));
 
       if (src_buffer == NULL)
         return;
-  
+
       g_return_if_fail (GTK_IS_TEXT_BUFFER (src_buffer));
 
       if (gtk_text_buffer_get_tag_table (src_buffer) !=
@@ -4000,9 +4002,7 @@ get_hadjustment (GtkTextView *text_view)
 {
   if (text_view->hadjustment == NULL)
     gtk_text_view_set_scroll_adjustments (text_view,
-                                          (GtkAdjustment*)
-                                          gtk_adjustment_new (0.0, 0.0, 0.0,
-                                                              0.0, 0.0, 0.0),
+                                          NULL, /* forces creation */
                                           text_view->vadjustment);
 
   return text_view->hadjustment;
@@ -4014,10 +4014,7 @@ get_vadjustment (GtkTextView *text_view)
   if (text_view->vadjustment == NULL)
     gtk_text_view_set_scroll_adjustments (text_view,
                                           text_view->hadjustment,
-                                          (GtkAdjustment*)
-                                          gtk_adjustment_new (0.0, 0.0, 0.0,
-                                                              0.0, 0.0, 0.0));
-
+                                          NULL); /* forces creation */
   return text_view->vadjustment;
 }
 
@@ -4164,7 +4161,7 @@ gtk_text_view_commit_handler (GtkIMContext  *context,
                                 0);
 }
 
-static void 
+static void
 gtk_text_view_preedit_changed_handler (GtkIMContext *context,
                                       GtkTextView  *text_view)
 {
@@ -4280,7 +4277,7 @@ append_action_signal (GtkTextView  *text_view,
   gtk_widget_show (menuitem);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 }
-       
+
 static void
 popup_menu_detach (GtkWidget *attach_widget,
                   GtkMenu   *menu)
@@ -4295,7 +4292,7 @@ gtk_text_view_popup_menu (GtkTextView    *text_view,
   if (!text_view->popup_menu)
     {
       GtkWidget *menuitem;
-      
+
       text_view->popup_menu = gtk_menu_new ();
 
       gtk_menu_attach_to_widget (GTK_MENU (text_view->popup_menu),
@@ -4512,14 +4509,14 @@ text_window_get_allocation (GtkTextWindow *win,
  * gtk_text_view_get_window:
  * @text_view: a #GtkTextView
  * @win: window to get
- * 
+ *
  * Retrieves the #GdkWindow corresponding to an area of the text view;
  * possible windows include the overall widget window, child windows
  * on the left, right, top, bottom, and the window that displays the
  * text buffer. Windows are %NULL and nonexistent if their width or
  * height is 0, and are nonexistent before the widget has been
  * realized.
- * 
+ *
  * Return value: a #GdkWindow, or %NULL
  **/
 GdkWindow*
@@ -4577,12 +4574,12 @@ gtk_text_view_get_window (GtkTextView *text_view,
  * gtk_text_view_get_window_type:
  * @text_view: a #GtkTextView
  * @window: a window type
- * 
+ *
  * Usually used to find out which window an event corresponds to.
  * If you connect to an event signal on @text_view, this function
  * should be called on <literal>event-&gt;window</literal> to
  * see which window it was.
- * 
+ *
  * Return value: the window type.
  **/
 GtkTextWindowType
@@ -4678,7 +4675,7 @@ buffer_to_text_window (GtkTextView   *text_view,
  * @buffer_y: buffer y coordinate
  * @window_x: window x coordinate return location
  * @window_y: window y coordinate return location
- * 
+ *
  * Converts coordinate (@buffer_x, @buffer_y) to coordinates for the window
  * @win, and stores the result in (@window_x, @window_y).
  **/
@@ -4738,7 +4735,7 @@ gtk_text_view_buffer_to_window_coords (GtkTextView      *text_view,
     case GTK_TEXT_WINDOW_PRIVATE:
       g_warning ("%s: can't get coords for private windows", G_STRLOC);
       break;
-      
+
     default:
       g_warning ("%s: Unknown GtkTextWindowType", G_STRLOC);
       break;
@@ -4817,7 +4814,7 @@ text_window_to_buffer (GtkTextView   *text_view,
  * @window_y: window y coordinate
  * @buffer_x: buffer x coordinate return location
  * @buffer_y: buffer y coordinate return location
- * 
+ *
  * Converts coordinates on the window identified by @win to buffer
  * coordinates, storing the result in (@buffer_x,@buffer_y).
  **/
@@ -4877,7 +4874,7 @@ gtk_text_view_window_to_buffer_coords (GtkTextView      *text_view,
     case GTK_TEXT_WINDOW_PRIVATE:
       g_warning ("%s: can't get coords for private windows", G_STRLOC);
       break;
-      
+
     default:
       g_warning ("%s: Unknown GtkTextWindowType", G_STRLOC);
       break;
@@ -4956,7 +4953,7 @@ set_window_height (GtkTextView      *text_view,
  * @text_view: a #GtkTextView
  * @type: window to affect
  * @size: width or height of the window
- * 
+ *
  * Sets the width of %GTK_TEXT_WINDOW_LEFT or %GTK_TEXT_WINDOW_RIGHT,
  * or the height of %GTK_TEXT_WINDOW_TOP or %GTK_TEXT_WINDOW_BOTTOM.
  * Automatically destroys the corresponding window if the size is set to 0,
@@ -5006,11 +5003,11 @@ gtk_text_view_set_border_window_size (GtkTextView      *text_view,
  * @text_view: a #GtkTextView
  * @width: a width in pixels
  * @height: a height in pixels
- * 
+ *
  * Sets the size request for the main text window (%GTK_TEXT_WINDOW_TEXT).
  * If the widget gets more space than it requested, the main text window
  * will be larger than this.
- * 
+ *
  **/
 void
 gtk_text_view_set_text_window_size (GtkTextView *text_view,
@@ -5045,7 +5042,7 @@ text_view_child_new_anchored (GtkWidget          *child,
                               GtkTextLayout      *layout)
 {
   GtkTextViewChild *vc;
-  
+
   vc = g_new (GtkTextViewChild, 1);
 
   vc->widget = child;
@@ -5059,7 +5056,7 @@ text_view_child_new_anchored (GtkWidget          *child,
                        vc);
 
   gtk_text_child_anchor_register_child (anchor, child, layout);
-  
+
   return vc;
 }
 
@@ -5100,7 +5097,7 @@ text_view_child_free (GtkTextViewChild *child)
     }
 
   g_object_unref (G_OBJECT (child->widget));
-  
+
   g_free (child);
 }
 
@@ -5156,7 +5153,7 @@ gtk_text_view_add_child_at_anchor (GtkTextView          *text_view,
   g_return_if_fail (child->parent == NULL);
 
   gtk_text_view_ensure_layout (text_view);
-  
+
   vc = text_view_child_new_anchored (child, anchor,
                                      text_view->layout);
 
index ec964bcf92695bfc443fffb17df5b4ca296182aa..9e52f2f97b6b59976bbf15d291a1ea4fb9972dba 100644 (file)
@@ -444,7 +444,7 @@ fill_example_buffer (GtkTextBuffer *buffer)
   gtk_object_set (GTK_OBJECT (tag),
                 "foreground_gdk", &color,
                 "background_gdk", &color2,
-                "font", "Sans 24",
+                  "size_points", 24.0,
                 NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "fg_red");
@@ -465,17 +465,17 @@ fill_example_buffer (GtkTextBuffer *buffer)
   color.blue = color.red = 0;
   color.green = 0xffff;
   gtk_object_set (GTK_OBJECT (tag),
-                "background_gdk", &color,
-                "font", "Sans 10",
-                NULL);
+                  "background_gdk", &color,
+                  "size_points", 10.0,
+                  NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "strikethrough");
 
   setup_tag (tag);
       
   gtk_object_set (GTK_OBJECT (tag),
-                "strikethrough", TRUE,
-                NULL);
+                  "strikethrough", TRUE,
+                  NULL);
 
 
   tag = gtk_text_buffer_create_tag (buffer, "underline");
@@ -483,30 +483,30 @@ fill_example_buffer (GtkTextBuffer *buffer)
   setup_tag (tag);
       
   gtk_object_set (GTK_OBJECT (tag),
-                "underline", PANGO_UNDERLINE_SINGLE,
-                NULL);
+                  "underline", PANGO_UNDERLINE_SINGLE,
+                  NULL);
 
   setup_tag (tag);
       
   gtk_object_set (GTK_OBJECT (tag),
-                "underline", PANGO_UNDERLINE_SINGLE,
-                NULL);
+                  "underline", PANGO_UNDERLINE_SINGLE,
+                  NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "centered");
       
   gtk_object_set (GTK_OBJECT (tag),
-                "justify", GTK_JUSTIFY_CENTER,
-                NULL);
+                  "justify", GTK_JUSTIFY_CENTER,
+                  NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "rtl_quote");
       
   gtk_object_set (GTK_OBJECT (tag),
-                "wrap_mode", GTK_WRAPMODE_WORD,
-                "direction", GTK_TEXT_DIR_RTL,
-                "indent", 30,
-                "left_margin", 20,
-                "right_margin", 20,
-                NULL);
+                  "wrap_mode", GTK_WRAPMODE_WORD,
+                  "direction", GTK_TEXT_DIR_RTL,
+                  "indent", 30,
+                  "left_margin", 20,
+                  "right_margin", 20,
+                  NULL);
   
   pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm);
   
index ec964bcf92695bfc443fffb17df5b4ca296182aa..9e52f2f97b6b59976bbf15d291a1ea4fb9972dba 100644 (file)
@@ -444,7 +444,7 @@ fill_example_buffer (GtkTextBuffer *buffer)
   gtk_object_set (GTK_OBJECT (tag),
                 "foreground_gdk", &color,
                 "background_gdk", &color2,
-                "font", "Sans 24",
+                  "size_points", 24.0,
                 NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "fg_red");
@@ -465,17 +465,17 @@ fill_example_buffer (GtkTextBuffer *buffer)
   color.blue = color.red = 0;
   color.green = 0xffff;
   gtk_object_set (GTK_OBJECT (tag),
-                "background_gdk", &color,
-                "font", "Sans 10",
-                NULL);
+                  "background_gdk", &color,
+                  "size_points", 10.0,
+                  NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "strikethrough");
 
   setup_tag (tag);
       
   gtk_object_set (GTK_OBJECT (tag),
-                "strikethrough", TRUE,
-                NULL);
+                  "strikethrough", TRUE,
+                  NULL);
 
 
   tag = gtk_text_buffer_create_tag (buffer, "underline");
@@ -483,30 +483,30 @@ fill_example_buffer (GtkTextBuffer *buffer)
   setup_tag (tag);
       
   gtk_object_set (GTK_OBJECT (tag),
-                "underline", PANGO_UNDERLINE_SINGLE,
-                NULL);
+                  "underline", PANGO_UNDERLINE_SINGLE,
+                  NULL);
 
   setup_tag (tag);
       
   gtk_object_set (GTK_OBJECT (tag),
-                "underline", PANGO_UNDERLINE_SINGLE,
-                NULL);
+                  "underline", PANGO_UNDERLINE_SINGLE,
+                  NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "centered");
       
   gtk_object_set (GTK_OBJECT (tag),
-                "justify", GTK_JUSTIFY_CENTER,
-                NULL);
+                  "justify", GTK_JUSTIFY_CENTER,
+                  NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "rtl_quote");
       
   gtk_object_set (GTK_OBJECT (tag),
-                "wrap_mode", GTK_WRAPMODE_WORD,
-                "direction", GTK_TEXT_DIR_RTL,
-                "indent", 30,
-                "left_margin", 20,
-                "right_margin", 20,
-                NULL);
+                  "wrap_mode", GTK_WRAPMODE_WORD,
+                  "direction", GTK_TEXT_DIR_RTL,
+                  "indent", 30,
+                  "left_margin", 20,
+                  "right_margin", 20,
+                  NULL);
   
   pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm);